<?php
namespace app\admin\controller;

use app\admin\model\Classroom;
use think\App;
use think\facade\View;

class Index extends Common
{
    protected $croomModel;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->croomModel = new Classroom();
    }

    public function index()
    {
        $showData = [];
        $showData['overdue'] = false;

        //计算到期时间
        $cid = session('adminUserInfo.cid');
        $croomInfo = $this->croomModel->findDetaiInfoById('start_time, end_time, status', $cid);
        if(strtotime($croomInfo['end_time']) && ((strtotime($croomInfo['end_time']) - time()) <= 7*60*60*24)){
            $showData['overdue'] = true;
            $showData['end_time'] = $croomInfo['end_time'];
        }
        if($croomInfo['status'] == 2){
            $showData['overdue'] = true;
            $showData['croomStatus'] = $croomInfo['status'];
        }

        View::assign($showData);
        return view();
    }

    public function hello($name = 'ThinkPHP6')
    {
        return 'hello,' . $name;
    }
}
